{% extends 'base.html' %}
{% load staticfiles %}
{% load i18n %}

{% load humanize %}

{% block head %}
  <link href="{% static 'css/questions.css' %}" rel="stylesheet">
  <script src="{% static 'js/questions.js' %}"></script>
{% endblock head %}

{% block page_content %}
<div id="mainbody">
    <div class="container">
  <ol class="breadcrumb">
    <li><a href="{% url 'questions' %}">{% trans "问答园" %}</a></li>
    <li class="active">{% trans "回答" %}</li>
  </ol>
  <div class="row question" question-id="{{ question.id }}">
    {% csrf_token %}
    <div class="col-md-1 options">
      {% if user in question.get_favoriters %}
        <span class="glyphicon glyphicon-star favorite favorited" title="Click to mark this question as favorite; click again to toggle"></span>
      {% else %}
        <span class="glyphicon glyphicon-star-empty favorite" title="Click to mark this question as favorite; click again to toggle"></span>
      {% endif %}
      <span class="favorite-count">{{ question.favorites }}</span>
    </div>
    <div class="col-md-11">
      <h2>{{ question.title }}</h2>
      <div class="question-user">
        <a href="{%url 'getuserinfo' question.user.id %}"><img src="{{ question.user.webuser.get_picture }}" class="img-circle" style='max-width:40px;'></a>
        <a href="{%url 'getuserinfo' question.user.id %}" class="username">{{ question.user.webuser.get_screen_name }}</a>
        <small class="asked">在{{ question.update_date|naturaltime }}提问</small>
      </div>
      <div class="question-description">
        {{ question.get_answercontent_as_markdown|safe }}
      </div>
      {% if question.get_tag_list %}
        <p>
          {% for tag in question.get_tag_list %}
            <span class="label label-primary">{{ tag }}</span>
          {% endfor %}
        </p>
      {% endif %}
    </div>
  </div>
  <h4 class="page-header">回答者</h4>
  <div class="answers">
    {% for answer in question.get_answers %}
      {% include 'questions/partial_answer.html' with question=question answer=answer %}
    {% endfor %}
    <h4>你的回答</h4>
    <form action="{% url 'answer' %}" method="post" role="form">
      {% csrf_token %}
      {{ form.question }}
      <div class="form-group">
        {% include 'markdown_editor.html' with textarea='id_answercontent' %}
        {{ form.answercontent }}
      </div>
      <div class="form-group">
        <button type="submit" class="btn brn-large btn-primary">{% trans "提交答案"%}</button>
      </div>
    </form>
  </div>
      </div></div>
{% endblock %}
